package com.yilin.tms.core.commons.model;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.yilin.commons.exception.BusinessException;
import com.yilin.tms.core.commons.base.BaseAuth;
import com.yilin.tms.core.commons.base.BaseCode;
import java.io.Serializable;

public class AuthData implements Serializable {


    public static void checkAuth(BaseAuth baseAuth, AuthItem authItem, String targetName,boolean isMe) {
        if (baseAuth == null || baseAuth.getAuthStatus() == AuthStatus.notApply) {
            throw new BusinessException(BaseCode.AUTH_ERR, String.format("%s未提交%s，%s",targetName,authItem.name,isMe?"请先提交认证":"请等待其提交认证"));
        }
        if (baseAuth.getAuthStatus() == AuthStatus.authFail) {
            throw new BusinessException(BaseCode.AUTH_ERR, String.format("%s的%s审核失败，%s",targetName,authItem.name,isMe?"请重新提交认证":"请等待其重新认证"));
        }
        if (baseAuth.getAuthStatus() == AuthStatus.waitProcess) {
            throw new BusinessException(BaseCode.AUTH_ERR, String.format("%s的%s正在审核中，%s",targetName,authItem.name,isMe?"请等待平台审核":"请先等待平台审核"));
        }
        if (baseAuth.getAuthStatus() == AuthStatus.authExpire) {
            throw new BusinessException(BaseCode.AUTH_ERR, String.format("%s的%s认证已失效，%s",targetName,authItem.name,isMe?"请重新提交认证":"请等待其重新提交"));
        }
    }

    public enum AuthItem {
        authIdCard(0, "身份证"),
        authBusinessLicense(1, "营业执照"),
        authDrivingLicense(2, "驾驶证"),
        authTransBusinessLicense(3, "道路运输经营许可证"),
        authQualificationCert(4, "道路运输从业资格证"),
        authTravelLicense(5, "行驶证"),
        authTransportLicense(6, "道路运输证"),
        authCompanySealStamp(7,"公司印章"),
        authPersonalSignetStamp(8,"个人签名"),
        authTaxCertification(9,"税务认证(贵州)");
        @EnumValue
        public Integer index;
        public String name;
        AuthItem(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    private AuthItem authItem;
    private BaseAuth authData;

    public AuthData(AuthItem authItem, BaseAuth authData) {
        this.authItem = authItem;
        this.authData = authData;
    }

    public AuthItem getAuthItem() {
        return authItem;
    }

    public void setAuthItem(AuthItem authItem) {
        this.authItem = authItem;
    }

    public BaseAuth getAuthData() {
        return authData;
    }

    public void setAuthData(BaseAuth authData) {
        this.authData = authData;
    }
}

